<?php
    class Login
    {
        public $userid = "Guest";
        private $pass = "";
        private $login = false;
        public $aid = 0;
		public $type = 0;
        public function __construct()
        {
        }
        public function getPassword()
        {
            return md5($this->pass);
        }
        public function isLoggedIn()
        {
            return $this->login;
        }
        public function loggedOut()
        {
            $this->login  = false;
            $this->userid = "Guest";
            $this->pass   = "";
            $this->aid    = 0;
            $this->type    = 0;
            //header('Location: index.php?module=logout');
        }
        public function login($user, $pass)
        {
            $this->userid = $user;
            $this->pass   = $pass;
            $this->pass   = $this->getPassword();
            if (trim($this->userid) == '' || trim($this->pass) == '')
            {
                return;
            } //trim($this->userid) == '' || trim($this->pass) == ''
            $sql = "SELECT aid, type, first_name FROM login WHERE (userid='%s' OR email='%s') AND password='%s'";
            Connection::getConnect();
            Connection::setQueryf($sql, $this->userid, $this->userid, $this->pass);
            $rslt        = Connection::fetch();
            $this->aid   = $rslt['aid'];
            $this->type   = $rslt['type'];
            $this->userid  = $rslt['first_name'];
            $this->login = ($this->aid > 0);
            if (!$this->login)
            {
                $this->userid = "Guest";
                $this->pass   = "";
            } //!$this->login
        }
    }
?>